package org.daochong.fastdev;

import org.daochong.lang.Properties;
import org.daochong.lang.ucm.Configuration;
import org.daochong.lang.ucm.ConfigurationContainer;

public class ActionConfigFactory implements IActionConfigFactory {

	public static String DEFAULT_GROUP_ID = "FastDevActionConfig";

	private String groupId = DEFAULT_GROUP_ID;

	public String getGroupId() {
		return groupId;
	}

	public void setGroupId(String groupId) {
		this.groupId = groupId;
	}

	private ConfigurationContainer container;

	public ConfigurationContainer getContainer() {
		return container;
	}

	public void setContainer(ConfigurationContainer container) {
		this.container = container;
	}

	public Properties getConfig(String id) {
		Configuration cfg = this.container.getConfiguration(id, getGroupId());
		if (cfg != null) {
			return cfg.getProperties();
		}
		return null;
	}

	public Properties getEntityConfig(String entity) {
		Configuration cfg = this.container.getConfiguration(entity, getGroupId());
		if (cfg != null) {
			return cfg.getProperties();
		}
		return null;
	}

}
